﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GuanCai_DaoHuo_Search.aspx.cs" Inherits="syc.Sale.GuanCai_DaoHuo_Search" %>

<head runat="server">
    <title></title>    
</head>
<body>
    <script type="text/javascript" language="javascript" src="/common.js"></script>
     <form id="form2" runat="server">
    <div id="wintop" class="wintop">管材到货查询</div>
    <asp:Panel ID="Panel1" runat="server" CssClass="panel" Visible="false">
    <input type="button" value="录 入" class="button" onclick="parent.swin2_load('/Fc/备件到货发货登记.aspx?io=in',600,350);"/>      
    <asp:Button ID="Button_Edit" runat="server" Text="修 改" CssClass="button" UseSubmitBehavior="False"/>
    <asp:Button ID="Button_Delete" runat="server" Text="删 除" CssClass="button"  
        UseSubmitBehavior="False" 
        OnClientClick="if(!confirm('确认要删除该条记录吗？'))return(false);" 
         />
</asp:Panel>  
        <asp:Panel ID="Panel2" runat="server" CssClass="panel" GroupingText="查 询">
            供货单位：<asp:DropDownList ID="GongHuoDanWei" runat="server" 
            DataSourceID="SqlDataSource2" DataTextField="名称" DataValueField="ID" 
                Width="110px">
        </asp:DropDownList>
            <span style="margin-left:28px;"></span>原 材 料：<asp:DropDownList ID="YuanCaiLiao" runat="server" 
            DataSourceID="SqlDataSource3" DataTextField="品名" DataValueField="ID" Width="220px" Font-Size="12px">
        </asp:DropDownList>    
        <span style="margin-left:28px;"></span>车 皮 号:  
            <asp:TextBox ID="CheHao" runat="server"  Width="80px"></asp:TextBox>
         <span style="margin-left:28px;"></span>暂估入库：<asp:DropDownList ID="Ruku" runat="server" 
            >
            <asp:ListItem  Value="-1">全部</asp:ListItem>
            <asp:ListItem  Value="1">入库</asp:ListItem>
            <asp:ListItem  Value="0">没入库</asp:ListItem>
        </asp:DropDownList>        
          <br/>
            开始日期：<asp:TextBox ID="Date1" runat="server" CssClass="intxt1" Width="110px"></asp:TextBox>
            <img align="middle" alt="" 
                onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" 
                src="/Icons/29.png" />&nbsp;&nbsp; 结束日期：<asp:TextBox ID="Date2" runat="server" 
                CssClass="intxt1" Width="140px"></asp:TextBox>
            <img align="middle" alt="" 
                onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" 
                src="/Icons/29.png" /> 
                <span style="margin-left:28px;"></span>
            <asp:Button ID="Button_Query" runat="server" CssClass="mbutton" 
                onclick="Button_Query_Click" Text="筛 选" UseSubmitBehavior="true" />
            <asp:Button ID="Button_Clear" runat="server" CssClass="mbutton" 
                onclick="Button_Clear_Click" Text="清空条件" UseSubmitBehavior="false" />
            <asp:Button ID="Button1" runat="server" CssClass="mbutton" 
                onclick="Button_To_Click" Text="导 出" UseSubmitBehavior="true" />
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
                SelectCommand="SELECT 0 as [ID], '全部' as [名称] union SELECT [ID], [名称] FROM [原料供货单位]">
            </asp:SqlDataSource>
            <span style="margin-left:28px;"></span> 
    </asp:Panel>
   
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
             SelectCommand="SELECT 0 as [ID], '全部' as [品名] UNION SELECT [ID], [品名]+'('+钢级+')'+规格 FROM [原料]">
        </asp:SqlDataSource>
     <asp:Panel ID="Panel3" runat="server" CssClass="panel2">
        <asp:Label ID="Message" runat="server" Text="·准备就绪" CssClass="prompt"></asp:Label>
    </asp:Panel>
     <div class="gridframe">
        <div class="gridview">
        
            <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
	            <tr>
		           <td class="grid-title"><div style="float:left;margin-top:3px;">原料到货记录</div><div style="float:right;">
                    <asp:DropDownList ID="PageSizeOption" runat="server" AutoPostBack="True" 
                        onselectedindexchanged="PageSizeOption_SelectedIndexChanged">
                    <asp:ListItem Value="10" >10 项/页</asp:ListItem>
                    <asp:ListItem Value="20" Selected="True">20 项/页</asp:ListItem>
                    <asp:ListItem Value="30">30 项/页</asp:ListItem>
                    <asp:ListItem Value="50">50 项/页</asp:ListItem>
                    <asp:ListItem Value="100">100 项/页</asp:ListItem>
                    </asp:DropDownList></div>
	            </td>		          
		        </tr>
		        <tr>
		            <td class="grid-back">            
                 <asp:SqlDataSource  ID="SqlDataSource1" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
                      SelectCommand="select t1.ID
,t1.原料ID
,t1.供货ID
,case when t1.分厂=0 then '待定'
when t1.分厂=1 then '一分厂'
when t1.分厂=2 then '二分厂'
when t1.分厂=3 then '三分厂'
when t1.分厂=4 then '四分厂'
when t1.分厂=5 then '五分厂'
else '未知分厂'
end as 使用单位
,t1.库区
,t1.日期
,t1.磅重1 
,t1.磅重2
,t1.磅重
,t1.标重
,t1.磅重-t1.标重 as 磅差
,t1.支数
,case when t1.状态=0 then '未送检'
when t1.状态=1 then '待检'
when t1.状态=2 then '合格'
when t1.状态=3 then '已发货'
else '未知状态'end as 状态描述
,case when t1.原料ID=1 then '油管光管(J55)'
when t1.原料ID=2 then '套管光管(J55)'
when t1.原料ID=3 then '油管接箍光管(J55)'
when t1.原料ID=4 then '套管接箍光管(J55)'
when t1.原料ID=5 then '成品油管接箍(J55)'
when t1.原料ID=6 then '成品套管接箍(J55)'
when t1.原料ID=101 then '油管光管(N80)'
when t1.原料ID=102 then '套管光管(N80)'
when t1.原料ID=103 then '油管接箍光管(N80)'
when t1.原料ID=104 then '套管接箍光管(N80)'
when t1.原料ID=105 then '成品油管接箍(N80)'
when t1.原料ID=106 then '成品套管接箍(N80)'
else '其他原料' end as 原料
,t2.名称 as 供货单位
,t1.车号
,t1.是否暂估入库
from 原料到货记录 t1
left outer join 原料供货单位 t2 on t2.ID=t1.供货ID" onselected="SqlDataSource1_Selected"
                      >
                     </asp:SqlDataSource>
                     <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid" 
                        DataSourceID="SqlDataSource1" 
                        PageSize="20"
                        GridLines="None" ondatabound="GridView1_DataBound" 
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False" DataKeyNames="ID" >
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <SelectedRowStyle   CssClass="grid-row-bright" />  
                        <Columns>                  
                            <asp:TemplateField HeaderText="车皮号">
                                <ItemTemplate>
                                    <asp:Label ID="Label_ch" runat="server" Text='<%# Eval("车号") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>
                            
                           <asp:BoundField DataField="供货单位" HeaderText="供货单位" 
                                    ItemStyle-CssClass="grid" HeaderStyle-CssClass="grid-header"
                                    ItemStyle-Width="100" >
                                <HeaderStyle CssClass="grid-header"></HeaderStyle>
                                <ItemStyle CssClass="grid" Width="100px" HorizontalAlign="Center">
                                </ItemStyle>
                                </asp:BoundField>
                                
                              <asp:BoundField DataField="原料" HeaderText="原料" SortExpression="原料"
                                    ItemStyle-CssClass="grid" HeaderStyle-CssClass="grid-header"
                                    ItemStyle-Width="120" >
                              <HeaderStyle CssClass="grid-header"></HeaderStyle>                            
                               <ItemStyle CssClass="grid" Width="120px" HorizontalAlign="Center"></ItemStyle>
                               </asp:BoundField>    
                              
                            
                            <asp:TemplateField HeaderText="磅重1(吨)" SortExpression="磅重1">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bz1" runat="server" Text='<%# Eval("磅重1") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="磅重2(吨)" SortExpression="磅重2">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bz2" runat="server" Text='<%# Eval("磅重2") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="磅重(吨)" SortExpression="磅重">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bz" runat="server" Text='<%# Eval("磅重") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>  
                                                     
                           <asp:TemplateField HeaderText="标重(吨)" SortExpression="标重">
                                <ItemTemplate>
                                    <asp:Label ID="Label_mybz" runat="server" Text='<%# Eval("标重") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="磅差(吨)">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bc" runat="server" Text='<%# Eval("磅差") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="支数(支)">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zs" runat="server" Text='<%# Eval("支数") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>
                            
                          
                            
                            <asp:TemplateField HeaderText="库区" SortExpression="库区">
                                <ItemTemplate>
                                    <asp:Label ID="Label_kq" runat="server" Text='<%# Eval("库区") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="40px" />
                            </asp:TemplateField>  
                            
                     
                            <asp:TemplateField HeaderText="到货日期" SortExpression="日期">
                                <ItemTemplate>
                                    <asp:Label ID="Label_rq" runat="server" Text='<%# Eval("日期","{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField>  
                           
                          <asp:TemplateField HeaderText="暂估入库" ItemStyle-CssClass="grid" HeaderStyle-CssClass="grid-header"
                             ItemStyle-HorizontalAlign="center" ItemStyle-Width="60">
                             <ItemTemplate>
                             <asp:CheckBox ID="CheckBox" runat="server" Checked='<%# Eval("是否暂估入库") %>' 
                                     ToolTip='<%# Eval("ID") %>' AutoPostBack="True" 
                                     oncheckedchanged="CheckBox_CheckedChanged" />
                            </ItemTemplate>

                          <ControlStyle CssClass="torf" />
                          <HeaderStyle CssClass="grid-header"></HeaderStyle>
                          <ItemStyle HorizontalAlign="Center" CssClass="grid" Width="60px"></ItemStyle>
                           </asp:TemplateField>
                            </Columns>                      
                          </asp:GridView>
		            </td>
	            </tr>
	            <tr>
		            <td>   
		                 <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                    ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                
                                <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><asp:Label ID="Label9" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>

		            </td>
	            </tr>
            </table>
            

        </div>
    </div>
    
    </form>
<script>
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }

    }
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
            rows[i].onclick = function() { this.firstChild.firstChild.click(); };
        }
    }
    var tds = document.getElementsByTagName("td");
    for (i = 0; i < tds.length; i++) {
        if (tds[i].className == "detailheader") {
            tds[i].innerHTML = tds[i].innerHTML.replace("*", "<span class=required>*</span>");
        }
    }
    var rows = document.getElementById("GridView1").rows;
    var sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
    var col = 3;
    if (rows[0].cells.length == 14) col = 5;
    for (i = 1; i < rows.length; i++) {
        sum1 += Number(rows[i].cells[col+2].innerText);
        sum2 += Number(rows[i].cells[col + 3].innerText);
        sum3 += Number(rows[i].cells[col + 4].innerText);
        sum4 += Number(rows[i].cells[col + 5].innerText);
    }
    var total = document.getElementById("Label_Total");
    total.innerHTML += " </br>本页小计（实际总磅量：" + fixFloatZ(sum1, 3) + " 吨 质保书总磅量：" + fixFloatZ(sum2, 3) + " 吨  磅差：" + fixFloatZ(sum3, 3) + " 吨 总支数：" + sum4 + " 支）";
    parent.hidesubmenu(true);
</script>
</body>
</html>
